/**
 * opportunitylog控制器
 *
 * @author sxf
 * @email sxf02615@163.com
 * @date 2025/1/15
 */
package com.sxf.crm.controller;


import com.sxf.crm.dto.OpportunityLogDTO;
import com.sxf.crm.entity.OpportunityLog;
import com.sxf.crm.service.OpportunityLogService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商机日志控制器
 */
@Slf4j
@RestController
@RequestMapping("/api/opportunities/{opportunityId}/logs")
@RequiredArgsConstructor
public class OpportunityLogController {

    private final OpportunityLogService opportunityLogService;

    @GetMapping
    @PreAuthorize("hasAuthority('opportunity:view')")
    public ResponseEntity<List<OpportunityLogDTO>> getOpportunityLogs(@PathVariable Long opportunityId) {
        log.info("查询商机日志列表: opportunityId={}", opportunityId);
        return ResponseEntity.ok(opportunityLogService.findByOpportunityId(opportunityId));
    }
}
